(function () {
  // 步骤3：创建echarts实例
  let myChart = echarts.init(document.querySelector(".box6"));
  console.log(myChart);

  // 步骤4：定义配置（指定图表的配置项和数据）
  var xAxisData = [];
  var data1 = [];
  var data2 = [];
  for (var i = 0; i < 100; i++) {
    xAxisData.push(i);
    data1.push((Math.sin(i / 8) * (i / 5) + i / 3) * 5);
    data2.push((Math.cos(i / 8) * (i / 5) + i / 3) * 5);
  }
  let option = {
    legend: {
      right: "35%",
      top: "90%",
      data: ["bar", "bar2"],
    },
    color: ["orange", "green"],
    xAxis: {
      data: xAxisData,
      splitLine: {
        show: false,
      },
      axisLine: {
        lineStyle: {
          color: "#ccc",
        },
        show: true,
      },
    },

    yAxis: {
      axisLine: {
        lineStyle: {
          color: "#ccc",
        },
        show: true,
      },
      axisTick: { show: false },
      splitLine: { show: false },
    },
    series: [
      {
        name: "bar",
        type: "bar",
        data: data1,
        emphasis: {
          focus: "series",
        },
        animationDelay: function (idx) {
          return idx * 10;
        },
      },
      {
        name: "bar2",
        type: "bar",
        data: data2,
        emphasis: {
          focus: "series",
        },
        animationDelay: function (idx) {
          return idx * 10 + 100;
        },
      },
    ],
    animationEasing: "elasticOut",
    animationDelayUpdate: function (idx) {
      return idx * 5;
    },
  };

  // 步骤5：使用刚指定的配置项和数据显示图表
  myChart.setOption(option);

  //   window.onresize = function () {
  //     myChart.resize();
  //   };
})();
